package cn.yunhe.lianxi;

public abstract class Person {
    protected String name;
    protected String sort;
    protected int hp;
    protected Wuqi wuqi;

    public Person(String name, String sort, Wuqi wuqi) {
        this.name = name;
        this.sort = sort;
        this.hp = 100;
        this.wuqi = wuqi;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public Wuqi getWuqi() {
        return wuqi;
    }

    public void setWuqi(Wuqi wuqi) {
        this.wuqi = wuqi;
    }

    //登场
    public void dengChang(){
        System.out.println(name+"("+this.sort+")"+"拿着"+wuqi.rName()+"进入战场！");
    }

    //攻击
    public void fight(Person person){
        int a=(int)(Math.random()*10);
        if(a>3){
            person.hp=person.hp-this.wuqi.Shoot();
            if(person.hp<0){
                person.hp=0;
            }
            System.out.println(name+"("+this.sort+")"+"拿着"+wuqi.rName()+",命中了"+person.name+"("+person.sort+"),"+person.name+"("+person.sort+")还剩"+person.hp+"点血");
        }else{
            System.out.println(name+"("+this.sort+")"+"未命中对方");
        }
    }

}
